<%@page import="com.gym.model.entity.User"%>
<%@page import="com.gym.model.entity.WeekDayForPlan"%>
<%@page import="com.gym.model.entity.WeekPlanning"%>
<%@page import="java.util.ArrayList"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>weekPlanning</title>
<jsp:include page="/jsp/menu.jsp" />
<link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath}/css/style.css" />

</head>
<%
ArrayList<WeekPlanning> weekPlanning = (ArrayList<WeekPlanning>)request.getAttribute("weekPlanning");
User user=(User) session.getAttribute("user");
%>

<body>

<div style="padding-top: 3%; padding-left: 0%;">
<table id="weekPlanning">
	<tr>
		<th>HOUR</th>	<th>#course</th>	<th>MONDAY</th>	<th>TUESDAY</th> <th>WEDNESDAY</th> <th>THURSDAY</th> <th>FRIDAY</th> <th>SATURDAY</th> <th>SUNDAY</th> 
	</tr>
<%
String tmpHour = "";
for(int i = 0; i < weekPlanning.size(); i++) {
	WeekPlanning wp = weekPlanning.get(i);
%>
	<tbody>
	<tr>
		<td><%=(tmpHour.equals(wp.getHour()) ? "" : wp.getHour())%></td> 
		<td align="center" ><%=wp.getItem()%></td>
	<%for(WeekDayForPlan dp : wp.getDayForPlan()) {%>
		<td>
		<%if(user!=null && user.isAdmin()) //admin???
		{
		%><a href="dominiUpdateCourse.do?id=<%=dp.getIdcourse()%>">
				<%=(dp.getActivity()==null ? "" : dp.getActivity())%>
			</a><%=(dp.getLifespan()==null ? "N.D." : "("+ dp.getLifespan()+"'')")%><br>
			<a href="dominiUpdateTrainer.do?id=<%=dp.getIdtrainer()%>">
				<%=(dp.getTrainerfirstname()==null ? "" : dp.getTrainerfirstname()+" "+dp.getTrainerlastname())%>
			</a>
		<%}else{ %>
			<a href="schedaCourse.do?idCourse=<%=dp.getIdcourse()%>">
				<%=(dp.getActivity()==null ? "" : dp.getActivity())%>
			</a><%=(dp.getLifespan()==null ? "N.D." : "("+ dp.getLifespan()+"'')")%><br>
			<a href="schedaTrainer.do?id=<%=dp.getIdtrainer()%>">
				<%=(dp.getTrainerfirstname()==null ? "" : dp.getTrainerfirstname()+" "+dp.getTrainerlastname())%>
			</a>
			<%} %>
			
		</td>
	<%}%>
	</tr>
	</tbody>
<%
	tmpHour = wp.getHour();
}
%>
</table>
</div>


</body>
</html>